package com.szx.usercenter.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.szx.usercenter.domain.SysRoleMenu;
import com.szx.usercenter.service.SysRoleMenuService;
import com.szx.usercenter.util.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author songzx
 * @create 2024-05-21 14:21
 */
@Api(tags = "角色菜单表")
@RestController
@RequestMapping("/sysRoleMenu")
public class SysRoleMenuController {
  @Autowired SysRoleMenuService sysRoleMenuService;

  @PostMapping("addRoleMenu")
  @ApiOperation("添加角色菜单")
  public Response addRoleMenu(@RequestBody SysRoleMenu sysRoleMenu) {
    return sysRoleMenuService.addRoleMenu(sysRoleMenu);
  }

  @GetMapping("getCheckedKeys")
  @ApiOperation("获取角色菜单")
  public Response getCheckedKeys(Long roleId) {
    return sysRoleMenuService.getCheckedKeys(roleId);
  }

  @PostMapping("getRoleMenu")
  @ApiOperation("获取角色菜单")
  public Response getRoleMenu(@RequestBody List<Long> roleIds) {
    LambdaQueryWrapper<SysRoleMenu> qw = new LambdaQueryWrapper<>();
    qw.in(SysRoleMenu::getRoleId, roleIds);
    return Response.rspData(sysRoleMenuService.list(qw));
  }
}
